<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 300px;
      }
      .block {
        width: 100px;
        height: 100px;
        margin: 20px;
        flex-shrink: 0;
        transform-origin: 50% 50%;
      }
      .block:nth-child(1) {
        background: red;
      }
      .block:nth-child(2) {
        background: blue;
      }
      .block:nth-child(3) {
        background: green;
      }
      .block:nth-child(4) {
        background: orange;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="block"></div>
      <div class="block"></div>
      <div class="block"></div>
      <div class="block"></div>
    </div>
    <script src="./js/Animate.js"></script>
    <script>
      const blocks = document.querySelectorAll(".block");
      const animator = new Animator({ duration: 1000, iterations: 1.5 });
      (async function () {
        let i = 0;
        while (true) {
          // eslint-disable-next-line no-await-in-loop
          await animator.animate(blocks[i++ % 4], ({ target, timing }) => {
            target.style.transform = `rotate(${timing.p * 360}deg)`;
          });
        }
      })();
    </script>
  </body>
</html>
